package com.zycfc.zsf.boot.mybatis.generator.codegen.model;

import java.util.*;

public class ConfigModel
{
    private String charset;
    private Database database;
    private Map<String, String> variables;
    private Templates templates;
    private List<Table> tables;
    private Files files;
    private GenAll genAll;
    
    public ConfigModel() {
        this.variables = new HashMap<String, String>();
        this.tables = new ArrayList<Table>();
        this.files = new Files();
    }
    
    public String getCharset() {
        return this.charset;
    }
    
    public void setCharset(final String charset) {
        this.charset = charset;
    }
    
    public Database getDatabase() {
        return this.database;
    }
    
    public void setDatabase(final Database database) {
        this.database = database;
    }
    
    public Map<String, String> getVariables() {
        return this.variables;
    }
    
    public void setVariables(final Map<String, String> variables) {
        this.variables = variables;
    }
    
    public Templates getTemplates() {
        return this.templates;
    }
    
    public void setTemplates(final Templates templates) {
        this.templates = templates;
    }
    
    public List<Table> getTables() {
        return this.tables;
    }
    
    public void setTables(final List<Table> tables) {
        this.tables = tables;
    }
    
    public Files getFiles() {
        return this.files;
    }
    
    public void setFiles(final Files files) {
        this.files = files;
    }
    
    public GenAll getGenAll() {
        return this.genAll;
    }
    
    public void setGenAll(final GenAll genAll) {
        this.genAll = genAll;
    }
    
    public class Database
    {
        private String dbHelperClass;
        private String url;
        private String username;
        private String password;
        
        public Database(final String dbType, final String url, final String username, final String password) {
            this.dbHelperClass = "com.zycfc.zsf.boot.mybatis.generator.codegen.db.impl.OracleHelper";
            if ("mysql".equals(dbType)) {
                this.dbHelperClass = "com.zycfc.zsf.boot.mybatis.generator.codegen.db.impl.MySqlHelper";
            }
            this.url = url;
            this.username = username;
            this.password = password;
        }
        
        public String getDbHelperClass() {
            return this.dbHelperClass;
        }
        
        public void setDbHelperClass(final String dbHelperClass) {
            this.dbHelperClass = dbHelperClass;
        }
        
        public String getUrl() {
            return this.url;
        }
        
        public void setUrl(final String url) {
            this.url = url;
        }
        
        public String getUsername() {
            return this.username;
        }
        
        public void setUsername(final String username) {
            this.username = username;
        }
        
        public String getPassword() {
            return this.password;
        }
        
        public void setPassword(final String password) {
            this.password = password;
        }
    }
    
    public class Templates
    {
        private String basepath;
        private Map<String, String> template;
        
        public Templates(final String basepath) {
            this.template = new HashMap<String, String>();
            this.basepath = basepath;
        }
        
        public String getBasepath() {
            return this.basepath;
        }
        
        public void setBasepath(final String basepath) {
            this.basepath = basepath;
        }
        
        public Map<String, String> getTemplate() {
            return this.template;
        }
        
        public void setTemplate(final Map<String, String> template) {
            this.template = template;
        }
    }
    
    public class Files
    {
        private String baseDir;
        private List<File> files;
        
        public Files() {
            this.baseDir = "";
            this.files = new ArrayList<File>();
        }
        
        public String getBaseDir() {
            return this.baseDir;
        }
        
        public void setBaseDir(final String baseDir) {
            this.baseDir = baseDir;
        }
        
        public void addFile(final String template, final String fileName, final String dir, final boolean sub, final boolean override, final boolean append, final String insertTag, final String startTag, final String endTag) {
            final File file = new File(template, fileName, dir, sub, override, append, insertTag, startTag, endTag);
            this.files.add(file);
        }
        
        public List<File> getFiles() {
            return this.files;
        }
        
        public void setFiles(final List<File> file) {
            this.files = file;
        }
        
        public class File
        {
            private String template;
            private String filename;
            private String dir;
            private boolean sub;
            private boolean override;
            private boolean append;
            private String insertTag;
            private String startTag;
            private String endTag;
            
            public File(final String template, final String filename, final String dir, final boolean sub, final boolean override, final boolean append, final String insertTag, final String startTag, final String endTag) {
                this.sub = false;
                this.override = false;
                this.append = false;
                this.insertTag = "";
                this.startTag = "start{tabname}";
                this.endTag = "end{tabname}";
                this.template = template;
                this.filename = filename;
                this.dir = dir;
                this.sub = sub;
                this.append = append;
                this.insertTag = insertTag;
                this.startTag = startTag;
                this.endTag = endTag;
                this.override = override;
            }
            
            public String getTemplate() {
                return this.template;
            }
            
            public void setTemplate(final String template) {
                this.template = template;
            }
            
            public boolean isSub() {
                return this.sub;
            }
            
            public void setSub(final boolean sub) {
                this.sub = sub;
            }
            
            public boolean isOverride() {
                return this.override;
            }
            
            public void setOverride(final boolean sub) {
                this.override = this.override;
            }
            
            public String getFilename() {
                return this.filename;
            }
            
            public void setFilename(final String filename) {
                this.filename = filename;
            }
            
            public String getDir() {
                return this.dir;
            }
            
            public void setDir(final String dir) {
                this.dir = dir;
            }
            
            public boolean getAppend() {
                return this.append;
            }
            
            public void setAppend(final boolean append) {
                this.append = append;
            }
            
            public String getInsertTag() {
                return this.insertTag;
            }
            
            public void setInsertTag(final String insertTag) {
                this.insertTag = insertTag;
            }
            
            public String getStartTag() {
                return this.startTag;
            }
            
            public void setStartTag(final String startTag) {
                this.startTag = startTag;
            }
            
            public String getEndTag() {
                return this.endTag;
            }
            
            public void setEndTag(final String endTag) {
                this.endTag = endTag;
            }
        }
    }
    
    public class Table
    {
        private String tableName;
        private Map<String, String> variable;
        private List<SubTable> subtable;
        
        public Table(final String tableName) {
            this.variable = new HashMap<String, String>();
            this.subtable = new ArrayList<SubTable>();
            this.tableName = tableName;
        }
        
        public String getTableName() {
            return this.tableName;
        }
        
        public void setTableName(final String tableName) {
            this.tableName = tableName;
        }
        
        public void addSubTable(final String tableName, final String foreignKey, final Map<String, String> vars) {
            final SubTable sb = new SubTable(tableName, foreignKey, vars);
            this.subtable.add(sb);
        }
        
        public Map<String, String> getVariable() {
            return this.variable;
        }
        
        public void setVariable(final Map<String, String> variable) {
            this.variable = variable;
        }
        
        public List<SubTable> getSubtable() {
            return this.subtable;
        }
        
        public void setSubtable(final List<SubTable> subtable) {
            this.subtable = subtable;
        }
        
        public class SubTable
        {
            private String tableName;
            private String foreignKey;
            private Map<String, String> vars;
            
            public SubTable(final String tableName, final String foreignKey, final Map<String, String> vars) {
                this.vars = new HashMap<String, String>();
                this.tableName = tableName;
                this.foreignKey = foreignKey;
                this.vars = vars;
            }
            
            public String getTableName() {
                return this.tableName;
            }
            
            public void setTableName(final String tableName) {
                this.tableName = tableName;
            }
            
            public String getForeignKey() {
                return this.foreignKey;
            }
            
            public void setForeignKey(final String foreignKey) {
                this.foreignKey = foreignKey;
            }
            
            public Map<String, String> getVars() {
                return this.vars;
            }
            
            public void setVars(final Map<String, String> vars) {
                this.vars = vars;
            }
        }
    }
    
    public class GenAll
    {
        private String tableNames;
        private List<File> file;
        
        public GenAll(final String tableNames) {
            this.file = new ArrayList<File>();
            this.tableNames = tableNames;
        }
        
        public String getTableNames() {
            return this.tableNames;
        }
        
        public void setTableNames(final String tableNames) {
            this.tableNames = tableNames;
        }
        
        public List<File> getFile() {
            return this.file;
        }
        
        public void setFile(final List<File> file) {
            this.file = file;
        }
        
        public class File
        {
            private String template;
            private String filename;
            private String extName;
            private String dir;
            private String genMode;
            private String sub;
            private Map<String, String> variable;
            
            public File(final String template, final String filename, final String extName, final String dir, final String genMode) {
                this.variable = new HashMap<String, String>();
                this.template = template;
                this.filename = filename;
                this.extName = extName;
                this.dir = dir;
                this.genMode = genMode;
            }
            
            public String getSub() {
                return this.sub;
            }
            
            public void setSub(final String sub) {
                this.sub = sub;
            }
            
            public String getTemplate() {
                return this.template;
            }
            
            public void setTemplate(final String template) {
                this.template = template;
            }
            
            public String getFilename() {
                return this.filename;
            }
            
            public void setFilename(final String filename) {
                this.filename = filename;
            }
            
            public String getExtName() {
                return this.extName;
            }
            
            public void setExtName(final String extName) {
                this.extName = extName;
            }
            
            public String getDir() {
                return this.dir;
            }
            
            public void setDir(final String dir) {
                this.dir = dir;
            }
            
            public String getGenMode() {
                return this.genMode;
            }
            
            public void setGenMode(final String genMode) {
                this.genMode = genMode;
            }
            
            public Map<String, String> getVariable() {
                return this.variable;
            }
            
            public void setVariable(final Map<String, String> variable) {
                this.variable = variable;
            }
        }
    }
}
